package pers.qianyu.month_202012.date_20201224;

import java.util.*;

/**
 * 455. 分发饼干
 * https://leetcode-cn.com/problems/assign-cookies/
 *
 * @author mizzle rain
 * @date 2020-12-24 16:14
 */
public class findContentChildren {
    public int findContentChildren(int[] g, int[] s) {
        Arrays.sort(g);
        Arrays.sort(s);
        int p1 = 0, p2 = 0, count = 0;
        while (p1 < g.length && p2 < s.length) {
            if (s[p2] >= g[p1]) {
                p1++;
                count++;
            }
            p2++;
        }
        return count;
    }
}
